package com.example.server.controller;

import com.example.server.pojo.*;
import com.example.server.service.impl.Impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@CrossOrigin
public class controller {
    @Autowired
    private Impl impl;
    @GetMapping("/getEducation")
    public Line getEducation(){
        return impl.getEducation();
    }
//    @GetMapping("/getEducationRatioIn25W")
//    public List<Rose> getEducationRatioIn25W(){
//        List<Education> Educations = impl.getEducationZhanbiIn25W();
//        List<Rose> roses = new ArrayList<>();
//        for (Education Education : Educations) {
//            Rose rose = new Rose();
//            rose.setName(Education.getEducation());
//            rose.setValue(Education.getRatio());
//            roses.add(rose);
//        }
//        return roses;
//    }
//    @GetMapping("/getEducationRatioIn25M")
//    public List<Rose> getEducationRatioIn25M(){
//        List<Education> Educations = impl.getEducationZhanbiIn25M();
//        List<Rose> roses = new ArrayList<>();
//        for (Education Education : Educations) {
//            Rose rose = new Rose();
//            rose.setName(Education.getEducation());
//            rose.setValue(Education.getRatio());
//            roses.add(rose);
//        }
//        return roses;
//    }
    @GetMapping("/getEducationRatioIn25")
    public List<Rose> getEducationRatioIn25(){
        List<Education> Educations = impl.getEducationZhanbiIn25();
        List<Rose> roses = new ArrayList<>();
        for (Education Education : Educations) {
            Rose rose = new Rose();
            rose.setName(Education.getEducation());
            rose.setValue(Education.getRatio());
            roses.add(rose);
        }
        return roses;
    }
    @GetMapping("/getCityLevelRatioIn25")
    public List<Rose> getCityLevelRatioIn25(){
        List<CityLevel> pojo1s = impl.getCityLevelRatioIn25();
        List<Rose> roses = new ArrayList<>();
        for (CityLevel pojo1 : pojo1s) {
            Rose rose = new Rose();
            rose.setName(pojo1.getCityLevel());
            rose.setValue(pojo1.getRatio());
            roses.add(rose);
        }
        return roses;
    }
    @GetMapping("/getIncomeRatioIn25")
    public List<Rose> getIncomeRatioIn25(){

        List<Income> pojo1s = impl.getIncomeRatioIn25();
        List<Rose> roses = new ArrayList<>();
        for (Income pojo1 : pojo1s) {
            Rose rose = new Rose();
            rose.setName(pojo1.getIncome());
            rose.setValue(pojo1.getRatio());
            roses.add(rose);
        }
        return roses;

    }
// pirnt
    @GetMapping("/getIncome")
    public Line getIncome(){
        return impl.getIncome();
    }
    @GetMapping("/getCityLevel")
    public Line getCityLevel(){
        return impl.getCityLevel();
    }
    @GetMapping("/getSex")
    public Line getSex(){
        System.out.println("1");
        return impl.getSex();
    }
}

// print